<script language="javascript">
        clearTimeout(window.interval);
        window.interval = setTimeout(function () {
            wx.ready(function () {
				$("#scan_shop").on('click',function () {
					var mid = scope.pagedata.mid;
					var merchid = scope.pagedata.merchid;
					var no_oneshop = scope.pagedata.no_oneshop;
					wx.scanQRCode({
						needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
						scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
						success: function (res) {
							FoxUI.loader.show('loading');
							var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
							var start = result.indexOf(',');
							result = result.substr(start+1);
							//alert(result);
							if(no_oneshop){
								if(mid){
									location.href = "{{}}"+"&mid="+mid+"&productsn="+result;
								}else if(merchid){
									location.href = "{{}}"+"&merchid="+merchid+"&productsn="+result;
								}else {
									location.href = "{{}}"+"&productsn="+result;
								}
							}else{
								if(mid){
									location.href = "{{}}"+"&mid="+mid+"&productsn="+result;
								}else if(merchid){
									location.href = "{{}}"+"&merchid="+merchid+"&productsn="+result;
								}else{
									location.href = "{{}}"+"&productsn="+result;
								}
							}						
						}
					});
				});
            });
        },500);
</script> 